﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using CellphoneRepair.DAL;
using CellphoneRepair.Entities;
using DevExpress.XtraEditors;

namespace CellphoneRepair.Forms
{
    public partial class EditType : DevExpress.XtraEditors.XtraForm
    {
        public EditType()
        {
            InitializeComponent();
        }

        private void EditType_Load(object sender, EventArgs e)
        {
            textEdit1.Text = Commons.GenerateIdByForeTag("PJT");
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textEdit2.Text))
            {
                Pjtype pjt = new Pjtype();

                pjt.Idpjtype = textEdit1.Text;

                pjt.Tpname = textEdit2.Text;

                using (PjtypeBll bll = new PjtypeBll())
                {
                    bll.Insert(pjt);
                    DialogResult = DialogResult.OK;
                }
            }
            else
            {
                textEdit2.ErrorText = "请填写类型名称";
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            ;
        }
    }
}